


import 'package:flutter_book/api/api.dart';
import 'package:flutter_book/data/model/video_model.dart';

class DouBanApi{

  static DouBanApi? _init;

  static DouBanApi init() {
    if (_init == null) {
      _init = DouBanApi();
    }
    return _init!;
  }

  //豆瓣的网址
  static const _dou_ban_http="https://movie.douban.com";

  //获取豆瓣视频列表
  static const _dou_ban_video_list_number="/j/new_search_subjects";



  //获取豆瓣视频列表
  Future<List<VideoModel>> getDouBanVideoListNumber({int number=20}) async {
    List<VideoModel> videoList=<VideoModel>[];
    Map<String, dynamic> params = {};
    params["sort"] = "U";
    params["range"] = "0,10";
    params["limit"] = number;
    String url=_dou_ban_http+_dou_ban_video_list_number;
    var data = await requestApi(url, params);
    if (data!=null) {
      videoList=data["data"].map<VideoModel>((e) => VideoModel.fromJson(e)).toList();
    }
    return videoList;
  }

}